package com.example.github.io.stream.byteArray;

import java.io.ByteArrayInputStream;
import java.io.IOException;

/**
 * ByteArrayInputStream 由两个词组成:ByteArray和InputStream。顾名思义，它可以用来读取字节数组作为输入流。
 */
public class ByteArrayInputStreamExample {
    public static void main(String[] args) throws IOException {
        // byte[] buff = {35, 36, 37, 38};
        String s = "this is ByteArrayInputStreamExample's test words!";
        // s = "你不抽我不抽，航空母舰谁来修";
        byte[] buff = s.getBytes();
        ByteArrayInputStream stream = new ByteArrayInputStream(buff);
        int k = 0;
        while ((k=  stream.read()) != -1) {
            char ch = (char) k;
            System.out.println("ASCII 码值是：" + k + " 对应的字符码值是：" + ch);
        }
        stream.close();
    }
}
